home *** CD-ROM | disk | FTP | other *** search
/ Complete Linux / Complete Linux.iso / docs / devel / tcl / tclx7_31.z / tclx7_31 / tcldev / tclX7.3a-p1 / tests / chroot.test < prev    next >
Encoding:
Text File  |  1994-01-23  |  2.1 KB  |  79 lines

  1. #
  2. # chroot.test
  3. #
  4. # Tests for the chroot command.
  5. #---------------------------------------------------------------------------
  6. # Copyright 1993 Karl Lehenbauer and Mark Diekhans.
  7. #
  8. # Permission to use, copy, modify, and distribute this software and its
  9. # documentation for any purpose and without fee is hereby granted, provided
  10. # that the above copyright notice appear in all copies.  Karl Lehenbauer and
  11. # Mark Diekhans make no representations about the suitability of this
  12. # software for any purpose.  It is provided "as is" without express or
  13. # implied warranty.
  14. #------------------------------------------------------------------------------
  15. # $Id: 
  16. #------------------------------------------------------------------------------
  17. #
  18.  
  19. if {[info procs test] != "test"} then {source testlib.tcl}
  20.  
  21. #
  22. # Fork without exec will not work under Tk, skip this test
  23. #
  24. if ![lempty [info commands button]] {
  25.     puts stderr "*************************************************************"
  26.     puts stderr "Chroot tests are constructed in a way that does not work"
  27.     puts stderr "under Tk.  Test skipped."
  28.     puts stderr "*************************************************************"
  29.     puts stderr ""
  30.     return
  31. }
  32.  
  33. Test chroot-1.1 {chroot tests} {
  34.     chroot
  35. } 1 {wrong # args: chroot path}
  36.  
  37. Test chroot-1.2 {chroot tests} {
  38.     chroot a b
  39. } 1 {wrong # args: chroot path}
  40.  
  41. if {[id user] != "root"} {
  42.     puts stderr "*************************************************************"
  43.     puts stderr "You are not running as `root', certain chroot tests will be"
  44.     puts stderr "skipped"
  45.     puts stderr "*************************************************************"
  46.     return
  47. }
  48.  
  49. #
  50. # clean up and create an empty test directory
  51. #
  52. exec rm -rf CHROOTDIR
  53. mkdir CHROOTDIR
  54.  
  55. #
  56. # since you can't chroot back up, we spawn a child process to do the
  57. # actual chroot
  58. #
  59. set pid [fork]
  60.  
  61. #
  62. # parent waits for child to complete
  63. #
  64. if {$pid > 0} {
  65.     wait $pid
  66.     exec rm -rf CHROOTDIR
  67.     return
  68. }
  69.  
  70. #
  71. # child tests chroot then exits
  72. #
  73. Test chroot-1.3 {chroot tests} {
  74.     chroot CHROOTDIR
  75.     glob -nocomplain /*
  76. } 0 {}
  77.  
  78. exit
  79.